import { defineView } from "@/routers/tools.mjs";

/**
 * @typedef {"warn" | "error" | "info" |"debug" | "log"} LoggerKind
 * @typedef {{warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void; info: (...args: unknown[]) => void; debug: (...args: unknown[]) => void; log: (...args: unknown[]) => void}} MyLog
 */
/**
 * @implements {ng.IController}
 */
class MyLogCtrl {
  static $inject = ["$scope", "$log", "$timeout"];

  /**
   * @param {ng.IScope} $scope
   * @param {ng.ILogService} $log
   * @param {ng.ITimeoutService} $timeout
   */
  constructor($scope, $log, $timeout) {
    this.$scope = $scope;
    this.$log = $log;
    this.$timeout = $timeout;
  }

  play() {
    // $(document).injector().get('$log').log('hello')
    this.$log.log("hello");
  }
}
/**
 * @type {DefineView}
 */
const PlayDecoratorView = defineView({
  controller: MyLogCtrl,
  controllerAs: "Ctrl",
  template: /* HTML */ html`
    <div>
      <h1>decorate Log</h1>
      <button class="btn bg-blue-200" ng-click="Ctrl.play()">Play</button>
    </div>
  `,
});

export default PlayDecoratorView;
